<template>
	<div>
		<div class="detailHead clearfix">
			<div class="headText fl">职位查看</div>
			<div :class="{'fr':true,'red':positionInfo.paystatus==='0'||positionInfo.status==='0','green':positionInfo.paystatus==='1'&&positionInfo.status==='1'}"
				v-html="positionInfo.realstatus" v-if="currentAction ==1 || currentAction ==2"></div>
		</div>
		<ul class="info clearfix">
			<li style="width: 100%" v-show="!houseshow">
				<div>公司名称 :</div>
				<!-- <div  v-html="company"></div> -->
				<span v-show="positionInfo.companyname" v-html="positionInfo.companyname"></span>
				<span v-show="positionInfo.isPlatformRecommend==1" style="font-size: 20px; color: rgb(51, 154, 203);">(平台合作)</span>
			</li>
			<li class="address" style="width: 100%">
				<div class="area fl">岗位工作地址:</div>
				<div class="right positionInfo-cityname">
					<div> {{positionInfo.cityname}}-{{positionInfo.areaname}}-{{positionInfo.address}}</div>
				</div>
			</li>
			<li>
				<div>职能 :</div>
				<div v-html="positionInfo.tradename"></div>
			</li>
			<li>
				<div>职位 :</div>
				<div v-html="positionInfo.positionname"></div>
			</li>
			<li>
				<div>岗位类型 :</div>
				<div v-html="positionInfo.talentname"></div>
			</li>
			<li>
				<div>所属行业 :</div>
				<div v-html="positionInfo.industrytypename"></div>
			</li>
			<li>
				<div>招聘人数 :</div>
				<div v-html="positionInfo.recruitment"></div>
			</li>
			<li>
				<div>学历要求 :</div>
				<div v-html="positionInfo.qualificationname"></div>
			</li>
			<li v-if="!(positionInfo.minage == 16 && positionInfo.maxage == 100)">
				<div>年龄范围 :</div>
				<div v-html="positionInfo.minage+'岁 ~ '+positionInfo.maxage +'岁'"></div>
			</li>
			<li v-show="positionInfo.wagetype == 2">
				<div>工作时间段 :</div>
				<div v-html="positionInfo.worktime"></div>
			</li>
			<li v-show="positionInfo.wagetype == 2">
				<div>工作天数 :</div>
				<div v-html="positionInfo.workday+'天'"></div>
			</li>

			<li v-show="positionInfo.worklifename">
				<div>工作经验 :</div>
				<div v-html="positionInfo.worklifename"></div>
			</li>
			<li v-show="positionInfo.wagetype != 2">
				<div>薪资待遇 :</div>
				<div v-html="positionInfo.offer"></div>
			</li>
			<li v-show="positionInfo.wagetype == 2">
				<div>时薪 :</div>
				<div v-html="positionInfo.miniwage + '元/小时'"></div>
			</li>
			<li v-if="positionInfo.wagetype != 2" v-show="!shows">
				<div>在职保障天数 :</div>
				<div v-html="positionInfo.entryday+'天'"></div>
			</li>
			<li v-show="!shows">
				<div>收费标准(元/人):</div>
				<div v-html="positionInfo.fullpersonalintegral + '元/人'"></div>
			</li>
			<li class="oneline mt-10">
				<div>福利待遇 : </div>
				<pre
					class="oneline-content"><span v-for="(item, index) in positionInfo.welfarename" :key="index">{{item}}</span></pre>
			</li>
			<li class="oneline" v-if="positionInfo.salaryStructure">
				<div>薪资架构 : </div>
				<pre v-html="positionInfo.salaryStructure" class="oneline-content"></pre>
			</li>
			<li class="oneline" style="width: 100%">
				<div>岗位描述 :</div>
				<pre v-html="positionInfo.jobcontent" class="oneline-content"></pre>
			</li>
			<li class="oneline" v-show="positionInfo.workduty">
				<div>任职要求 :</div>
				<pre v-html="positionInfo.workduty" class="oneline-content"></pre>
			</li>

			<li class="oneline" v-if="positionInfo.interviewRequest">
				<div>面试要求 : </div>
				<pre v-html="positionInfo.interviewRequest" class="oneline-content"></pre>
			</li>
		</ul>
		<ul class="postInfo">
			<li>
				<div>发布时间 :</div>
				<div v-html="positionInfo.insertdate"></div>
			</li>
			<li style v-show="!houseshow">
				<div>发布人 :</div>
				<div v-html="positionInfo.nickname" style="color:#409EFF;cursor:pointer" @click="postManDetail"></div>
			</li>
			<li style  v-show="houseshow">
				<div>雇主 :</div>
				<div v-html="positionInfo.username" style="color:#409EFF;cursor:pointer" @click="postManDetail"></div>
			</li>
		</ul>
		<el-dialog :visible.sync="dialogVisible" width="70%" :before-close="handleClose" append-to-body
			custom-class="people_dialog" class="social_inner_dialog">
			<div class="dialog-title" slot="title">
				<dialog-title :slot-str="true" :title="userDetail.nickname">

				</dialog-title>
			</div>
			<div class="dialog-main">
				<div class="baseinfo">
					<div class="title">基本信息</div>
					<ul>
						<li class="clearfix">
							<div class="left">
								<span>会员名称 : {{userDetail.nickname}}</span>
							</div>
							<div class="right">
								<span>性别 :</span>
								<span v-if="userDetail.sex==='0'">未填</span>
								<span v-if="userDetail.sex==='1'">男</span>
								<span v-if="userDetail.sex==='2'">女</span>
							</div>
						</li>
						<li class="clearfix">
							<div class="left">
								<span>出生日期 : {{userDetail.birthdate}}</span>
							</div>
							<div class="right">
								<span>居住地 :</span>
								<span>{{userDetail.regionname}}</span>
							</div>
						</li>
						<li class="clearfix">
							<div class="left">
								<span>手机号码 : {{userDetail.telnum}}</span>
							</div>
						</li>
					</ul>
				</div>
				<div class="platform">
					<div class="title">平台信息</div>
					<div class="content clearfix">
						<div class="left">
							<span>平台注册时间 :</span>
							{{userDetail.registertime.split(" ")[0]}}
						</div>
					</div>
				</div>
			</div>
		</el-dialog>
	</div>
</template>
<script>
	import dialogTitle from "../../common/title.vue";
	export default {
		name: "",
		components: {
			dialogTitle
		},
		props: ["id", "type", "remark", "company", "currentAction", "shows", "houseshow"],
		data() {
			return {
				options:[],
				subLevelModelList:[],
				workersList: [],
				positionInfo: {},
				totalMoney: "",
				userDetail: {
					registertime: ""
				},
				dialogVisible: false
			};
		},
		mounted() {
			console.log(this.houseshow);
			this.getInfo();
			console.log(this.positionInfo);
		},
		methods: {
			getInfo() {
				if (this.houseshow) {
					this.$ceshiGetAxios("v1/house/SeletPositionById", {
						positionid: this.id
					}).then(res => {
						if ((res.data.message = "success.")) {
							let base = require('../../../assets/mask/baseGeneral.json');
							let education = base.education; //教育背景
							let workExperiencePosition = base.workExperiencePosition; //工作经验
							let salaryType = base.salaryType; //薪资类型
							let welfareList = base.welfare; //福利
							let positionType=base.positionType//岗位类型
							this.positionInfo = res.data.data;
							let result = res.data.data;
							if (result.welfare != undefined) {
								let welfarelist1 = result.welfare.split(';')
								this.positionInfo.welfarename=[];
								for (var i in welfarelist1) {
									for (var k in welfareList) {
									if(welfareList[k].code==welfarelist1[i]){
										this.positionInfo.welfarename.push(welfareList[i].name+';')
									}

									}
								}

							}
							let indutry = require('../../../assets/mask/select_industry.json');
							 let positionList = indutry.tradeList
							for (var i in positionList) {
								for (var k in positionList[i].subLevelModelList) {
									this.subLevelModelList.push( positionList[i].subLevelModelList[k])
								}
							
							}
							if (result.industrytype != undefined) {
								for (var i in this.subLevelModelList) {
									if (result.industrytype == this.subLevelModelList[i].code) {
										  result.industrytypename= this.subLevelModelList[i].name
									}
								}
							}
							
							
							
							if (result.talenttype != undefined) {
								for (var i in positionType) {
									if (result.talenttype == positionType[i].code) {
										  result.talentname= positionType[i].name
									}
								}
							}
							
							if (result.qualification != undefined) {
								for (var i in positionType) {
									if (result.qualification == education[i].code) {
										  result.qualificationname= education[i].name
									}
								}
							}
							
							let city = require('../../../assets/mask/city.json');
							this.options = city.city; //工作城市
							for (var i in this.options) {
								for (var k in this.options[i].children) {
									if ( result.city == this.options[i].children[k].value) {
										result.cityname = this.options[i].children[k].label
									}
									for (var z in this.options[i].children[k].children) {
										if (result.area == this.options[i].children[k].children[z].value) {
											result.areaname= this.options[i].children[k].children[z].label
										}
									}
							
								}
							
							}
							if (!result.miniwage && result.maxwage) {
								result.offer = `${parseInt(result.maxwage) / 1000}K以下`;
							} else if (!result.maxwage && result.miniwage) {
								result.offer = `${parseInt(result.miniwage) / 1000}K以上`;
							} else {
								result.offer =
									`${parseInt(result.miniwage) / 1000}-${parseInt(
							  result.maxwage
							) / 1000}K`;
							}
							console.log(result.offer);
							if (result.tradeidname == undefined) {
								let workers = require('../../../assets/mask/positionList.json');
								this.workersList = workers.position; //职能类型
								for (var i in this.workersList) {
									for (var k in this.workersList[i].children) {
										// console.log(this.workersList[i].children[k].value,'value');
										if (result.tradeid == this.workersList[i].children[k].value) {
											console.log(this.workersList[i].children[k].value, 'vulue');
											result.tradeidname = this.workersList[i].children[k].label
										}
									}

								}
							}
						}
					})
				} else {
					this.$ceshiAxios
						.post("/v1/recruit/stationInfo", {
							positionid: this.id
						})
						.then(res => {
							if ((res.data.message = "success.")) {
								this.positionInfo = res.data.data;
								// this.positionInfo.welfarename = this.positionInfo.welfarename.replace( /;/g,"  " );
								let result = res.data.data;
								


								if (result.tradeidname == undefined) {
									let workers = require('../../../assets/mask/positionList.json');
									this.workersList = workers.position; //职能类型
									for (var i in this.workersList) {
										for (var k in this.workersList[i].children) {
											// console.log(this.workersList[i].children[k].value,'value');
											if (result.tradeid == this.workersList[i].children[k].value) {
												console.log(this.workersList[i].children[k].value, 'vulue');
												result.tradeidname = this.workersList[i].children[k].label
											}
										}

									}
								}
								
								 

								if (!result.miniwage && result.maxwage) {
									result.offer = `${parseInt(result.maxwage) / 1000}K以下`;
								} else if (!result.maxwage && result.miniwage) {
									result.offer = `${parseInt(result.miniwage) / 1000}K以上`;
								} else {
									result.offer =
										`${parseInt(result.miniwage) / 1000}-${parseInt(
                result.maxwage
              ) / 1000}K`;
								}
								if (result.paystatus === "0") result.realstatus = "未支付";
								if (result.status === "0") result.realstatus = "已下架";
								if (result.status === "1" && result.paystatus === "1")
									result.realstatus = "招聘中";
								if (!result.ishighquality) {
									this.totalMoney =
										parseInt(this.positionInfo.discountpersonal) *
										this.positionInfo.recruitment +
										".00元";
								} else if (result.ishighquality === "0") {
									this.totalMoney =
										parseInt(this.positionInfo.discountpersonal) *
										this.positionInfo.recruitment *
										0.8 +
										".00元";
								} else if (result.ishighquality === "1") {
									this.totalMoney =
										parseInt(this.positionInfo.discountposition) *
										this.positionInfo.recruitment *
										0.9 +
										".00元";
								}

								if (!result.miniwage) {
									var aver = Number(result.maxwage) / 2;
								} else if (!result.maxwage) {
									var aver = Number(result.miniwage) / 2;
								} else {
									var aver = (Number(result.miniwage) + Number(result.maxwage)) / 2;
								}
								if (aver > 40000) {
									aver = aver;
								} else if (aver > 30000 && aver < 40000) {
									aver = aver * 0.5;
								} else if (aver > 20000 && aver < 30000) {
									aver = aver * 0.3;
								} else if (aver > 10000 && aver < 20000) {
									aver = aver * 0.15;
								} else {
									aver = aver * 0.1;
								}
								this.positionInfo.aver = aver;

								this.positionInfo.welfarename = result.welfarename.split(";");
								this.positionInfo.welfarename.pop();

								if (!this.positionInfo.hasOwnProperty("ishighquality")) {
									this.positionInfo.discount = 1;
								} else {
									switch (this.positionInfo.ishighquality) {
										case "0":
											this.positionInfo.discount = 0.8;
											break;
										case "1":
											this.positionInfo.discount = 0.9;
											break;
									}
								}
							} else {
								this.$message({
									message: res.data.message,
									type: "error"
								});
							}
						});
				}
			},
			post() {
				this.$confirm(
						`该岗位需要支付${parseInt(
          this.positionInfo.discountposition
        )},您确定支付吗?`,
						"提示", {
							confirmButtonText: "确定",
							cancelButtonText: "取消",
							type: "warning"
						}
					)
					.then(() => {
						this.positionInfo.paytype = "1";
						this.$axios
							.post("/app/v1/ent/position/insert", this.positionInfo)
							.then(res => {
								if (res.data.message === "success.") {
									this.$message({
										message: "支付成功",
										type: "success"
									});
									this.cancle(false);
								} else {
									this.$message({
										message: res.data.message,
										type: "error"
									});
								}
							});
					})
					.catch(() => {
						this.$message({
							type: "info",
							message: "已取消支付"
						});
					});
			},
			cancle(f) {
				this.$emit("cancle", f);
			},
			handleClose() {
				this.dialogVisible = false;
			},
			postManDetail() {
				this.dialogVisible = true;
				let obj = {
					userid: this.positionInfo.userid
				};
				this.$axios.post("/app/v1/platform/member/detail", obj).then(resp => {
					if (resp.data.code === 1) {
						this.userDetail = resp.data.data;
					}
				});
			}
		}
	};
</script>
<style lang='less' scoped>
	.detailHead {
		padding: 20px 50px 20px 20px;
		border-bottom: 1px solid #d2d2d2;

		.headText {
			font-size: 18px;
			font-weight: 600;
		}
	}

	.info {
		li {
			float: left;
			width: 50%;
			padding: 12px 0;
			text-align: left;

			>div:nth-child(1) {
				display: inline-block;
				width: 120px;
				text-align: right;
				color: #909090;
				padding-right: 5px;
			}

			>div:nth-child(2) {
				display: inline-block;
				color: #404040;
			}
		}

		.oneline {
			width: 100%;
			box-sizing: border-box;
			line-height: 20px;
			padding: 14px 0 12px 120px;
			position: relative;

			>div {
				position: absolute;
				top: 14px;
				left: 0;
			}

			>.oneline-content {
				width: 100%;
				padding-right: 20px;
				padding-left: 4px;
			}
		}
	}

	.postInfo {
		border-top: 1px dashed #d2d2d2;
		// padding-top: 20px;
		text-align: left;

		li {
			line-height: 40px;

			div:nth-child(1) {
				display: inline-block;
				width: 120px;
				text-align: right;
				padding-right: 5px;
				color: #909090;
			}

			div:nth-child(2) {
				display: inline-block;
				color: #404040;
			}
		}
	}

	// .fl {
	//   float: left;
	// }

	// .fr {
	//   float: right;
	// }
	.place {
		vertical-align: top;
	}

	// .Working {
	//   width: 350px;
	//   line-height: 20px;
	//   white-space: pre-wrap;
	//   word-wrap: break-word;
	//   vertical-align: top;
	// }

	.red {
		color: #f72e2e !important;
		font-size: 18px;
	}

	.green {
		color: #31c746 !important;
		font-size: 18px;
	}

	pre {
		// line-height: 20px;
		white-space: pre-wrap;
		/* Since CSS 2.1 */
		word-wrap: break-word;

		/* Internet Explorer 5.5+ */
		span {
			display: inline-block;
			width: 80px;
		}
	}

	.province,
	.cityname {
		padding-right: 15px;
		color: #404040;
	}

	.right {
		color: #404040;
		float: left;
		text-align: left;
	}

	.fl {
		float: left;
	}

	.fr {
		float: right;
	}

	.pay {
		width: 100%;
		// background: #000;
	}

	// .positionInfo-cityname{
	//   width: 300px;
	//   background: #000;
	// }
	.dialog-main {
		padding-bottom: 50px;

		.baseinfo {
			border-bottom: 1px dashed #dcdcdc;

			.title {
				padding: 20px 0;
			}

			li {
				padding-bottom: 20px;
				padding-left: 30px;

				.left {
					float: left;
					width: 50%;
				}

				.right {
					float: left;

					span:first-child {
						display: inline-block;
						width: 100px;
						text-align: right;
					}

					span:last-child {
						display: inline-block;
						width: 80px;
						text-align: left;
					}
				}
			}
		}

		.platform {
			.title {
				padding: 30px 0 20px;
			}

			.content {
				padding-left: 30px;

				>div {
					float: left;
					width: 50%;
				}

				.right {
					span {
						display: inline-block;
						width: 100px;
						text-align: right;
					}
				}
			}
		}
	}

	.dialog-title {
		padding: 20px 0;
		padding-right: 30px;
		position: relative;

		.toInfo {
			color: #0064e4;
			position: absolute;
			top: 24px;
			right: 30px;
			cursor: pointer;
		}
	}
</style>
<style>
	.social_inner_dialog {
		padding: 30px;
	}

	.social_inner_dialog .el-dialog__header {
		border-bottom: 1px solid #e6e6e6;
	}

	.treatment {
		/* text-align: center; */
		padding-right: 4px;
	}

	pre {
		line-height: 20px;
		margin-left: 5px;
		white-space: pre-wrap;
		word-wrap: break-word;
	}

	pre span {
		display: inline-block;
		width: 80px;
	}

	.mt-10 {
		margin-top: 10px;
	}
</style>
